package com.zhongge.servlet;

import com.zhongge.entity.Student;
import com.zhongge.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName UpdateServlet
 * @Description TODO
 * @Author zhongge
 * @Version 1.0
 */
@WebServlet("/update")
public class UpdateServlet extends HttpServlet {
    StudentService studentService = new StudentService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //更具id获取当前对象
        //获取id 根据id得出当前操作的学生对象
        String id = req.getParameter("id");
        Student student = studentService.getById(Integer.parseInt(id));

        //将当前对象装在req中
        req.setAttribute("student", student);
        //转到edit.jsp
        req.getRequestDispatcher("student/edit.jsp").forward(req, resp);
    }
}
